<? /* license

BilugCMS (http://www.bilug.it) - Content Management System for dynamic web sites
Copyright (C) 2005-2008  Federico Villa and Alessio Loro Piana

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

For reference, contact bilugcms@vilnet.it


license */ ?>
<?php
 
header("Content-Type: text/xml;charset=iso-8859-1");

require_once("utility/connessione.php");	
	$nomeserver = "http://".$_SERVER['SERVER_NAME'];	
	//count all the articles that are current and published
	$num_rows = mysql_num_rows(mysql_query("SELECT * from statiche"));  
	
	//select them and put them into a dataset called $result
	$query = "select ID from statiche" ;
	$result = mysql_query($query) or die("Query failed");
	
	//this is the normal header applied to any Google sitemap.xml file
	echo "<?xml version='1.0' encoding='UTF-8'?>
	<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"
	xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
	xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9
	http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\">";
	
	$url_product = $nomeserver.'/html/index.php';
	echo 
		'
			<url>
			<loc>'.$url_product.'</loc>
			<lastmod></lastmod>
			<changefreq>daily</changefreq>
			<priority>1.0</priority>
			</url>
		';
	//loop through the entire resultset
	
	for($i=0;$i<$num_rows; $i++)
	{
		$control=mysql_fetch_row($result);
		//your url-product as we worked out in #4
		$url_product = $nomeserver.'/html/index.php?pag=statiche.php&amp;stat='.$control[0];
		
		$displaydate = $control[1];
						
		//you can assign whatever changefreq and priority you like
		echo 
		'
			<url>
			<loc>'.$url_product.'</loc>
			<lastmod></lastmod>
			<changefreq>daily</changefreq>
			<priority>0.9</priority>
			</url>
		';
		
		
	}
	
	$num_rows = mysql_num_rows(mysql_query("SELECT * from notizie WHERE autorizza='si'"));  
	
	//select them and put them into a dataset called $result
	$query = "select ID , DATE_FORMAT(data,'%Y-%m-%d') from notizie WHERE autorizza='si' ORDER BY data DESC" ;
	$result = mysql_query($query) or die("Query failed");
	
	//loop through the entire resultset
	
	for($i=0;$i<$num_rows; $i++)
	{
		$control=mysql_fetch_row($result);
		//your url-product as we worked out in #4
		$url_product = $nomeserver.'/html/index.php?pag=news.php&amp;news='.$control[0];
		
		$displaydate = $control[1];
						
		//you can assign whatever changefreq and priority you like
		echo 
		'
			<url>
			<loc>'.$url_product.'</loc>
			<lastmod>'.$displaydate.'</lastmod>
			<changefreq>daily</changefreq>
			<priority>0.7</priority>
			</url>
		';
		
		
	}
	
	$num_rows = mysql_num_rows(mysql_query("SELECT * from eventi"));  
	
	//select them and put them into a dataset called $result
	$query = "select ID , DATE_FORMAT(dataora,'%Y-%m-%d') from eventi ORDER BY dataora DESC" ;
	$result = mysql_query($query) or die("Query failed");
		
	//loop through the entire resultset
	
	for($i=0;$i<$num_rows; $i++)
	{
		$control=mysql_fetch_row($result);
		//your url-product as we worked out in #4
		$url_product = $nomeserver."/html/index.php?pag=mese_eventoapp.php&amp;id=".$control[0]."&amp;mese=".substr($control[1],5,2);
				
		$displaydate = $control[1];
						
		//you can assign whatever changefreq and priority you like
		echo 
		'
			<url>
			<loc>'.$url_product.'</loc>
			<lastmod>'.$displaydate.'</lastmod>
			<changefreq>daily</changefreq>
			<priority>0.8</priority>
			</url>
		';
		
		
	}
	mysql_close(); //close connection

	//close the XML attribute that we opened in #3
	echo
	'</urlset>';

?>
